import { http } from '@/utils/http'
import type { LoginData, LoginResult, AsyncRoutesResult } from './types'

const AuthAPI = {
  /** 初始化账号 */
  init() {
    return http.request<ResponseData>('post', '/init')
  },
  /** 登录 */
  login(data: LoginData) {
    return http.request<LoginResult>('post', '/login', { data })
  },
  /** 获取异步路由 */
  getAsyncRoutes() {
    return http.request<AsyncRoutesResult>('get', '/routes');
  },
  logout() {
    return http.request<ResponseData>('post', '/logout')
  }
}

export default AuthAPI
